
export const formatPriceStr =  (str: string) => {
     // let priceStr = ''
     let pointIdx = str.indexOf('.')
     let integer = ''
     let decimal = ''

     if (pointIdx > -1) {
         integer = str.substr(0, pointIdx)
         decimal = str.substr(pointIdx)
     } else {
         integer = str
     }

     var num = 0
     var arr = []
     for (var i = integer.length - 1; i >= 0; i -= 1) {
         arr.push(integer[i])
         if ((num + 1) % 3 === 0 && i !== 0) {
             arr.push(',')
         }
         num += 1
     }
     
     return arr.reverse().join('') + decimal
}

export const showPhone = (val: string) => {
    return val.replace(/(\d{3})(\d{4})(\d{4})/, '$1****$3')
}
export const urlArgs = () => {
    var args = {}
    var query = location.search.substring(1)
    var pairs = query.split('&')
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=')
        if (pos === -1) {
            continue
        }
        var name = pairs[i].substring(0, pos)
        var value = pairs[i].substring(pos + 1)
        args[name] = value
    }
    return args
}